{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>入驻企业</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">
            <input type="hidden" name="id" value="{$info['sup_id']}">
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">企业列表：</label>
                <div class="layui-input-block">
                    <select name="company_id" xm-select="select3"  lay-verify="required" xm-select-search="" xm-select-search-type="dl">
                        {volist name="aa" id="vo"}
                         <option value="{$vo['s_id']}">{$vo['s_name']}(<font style="color:red">商家金额 : {$vo['s_money']}</font>)</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">状态：</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="1" title="收费" checked lay-filter="component-form-element1">
                    <input type="radio" name="status" value="2" title="免费" lay-filter="component-form-element1">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8 money">
                <label class="layui-form-label">输入收费金额：</label>
                <div class="layui-input-block">
                    <input type="text" name="money"  placeholder="" class="layui-input" onkeyup="this.value=this.value.replace(/\D/gi,'')">
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                    <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer" /}

<script>

    layui.use(['form'], function() {
        var form = layui.form;
        form.on('radio(component-form-element1)', function(data){
           if(data.value==1){
                $(".money").show();
           }else{
               $(".money").hide();
           }
        });
        form.on('submit(component-form-element)', function (data) {
            var type = $('input[name="status"]:checked').val();
            var m = $('input[name="money"]').val().trim();
            if(type == 1){
                if(m == '' || m <= 0){
                    alert('金额不能为空且必须大于0');
                    return;
                }
            }
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('relation')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('doyen/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
                    }
                }
            })
        });
    });
</script>
</body>
</html>